package com.dufcal.repondeursms;

import java.util.ArrayList;

import android.content.ContentValues;
import android.net.Uri;
import android.telephony.SmsManager;

public class Sms {

	public String message;
	public String heure;
	public String contact;

	public Sms(String texte, String heure, String contact) {

		this.heure = heure;
		this.message = texte + heure + "  "
				+ Appli.appli.getString(R.string.suffixe);
		this.contact = contact;

	}

	public String getMessage() {
		return message;
	}

	public void sendSMS() {
		// Log.v("sms", "Envoi du message");

		/* ecrire dans la sendbox */
		try {
			ContentValues values = new ContentValues();
			values.put("address", this.contact);
			values.put("body", this.message);
			Appli.appli.getContentResolver().insert(
					Uri.parse("content://sms/sent"), values);
		} catch (Exception e) {
		}

		/* envoyer le sms */
		SmsManager sms = SmsManager.getDefault();
		ArrayList<String> preparatedMessage = sms.divideMessage(this.message);
		sms.sendMultipartTextMessage(this.contact, null, preparatedMessage,
				null, null);

	}

}
